﻿// -----------------------------------------------------------------------
// <copyright file="EventFiringScope.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace PMOMEventReceivers
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;

    public class DisabledItemEventsScope : SPItemEventReceiver, IDisposable
    {
        private bool eventFiringEnabledStatus;
        public DisabledItemEventsScope()
        {
            eventFiringEnabledStatus = base.EventFiringEnabled;
            base.EventFiringEnabled = false;
        }

        #region IDisposable Members
        public void Dispose()
        {
            base.EventFiringEnabled = eventFiringEnabledStatus;
        }
        #endregion
    }

    public class EnabledItemEventsScope : SPItemEventReceiver, IDisposable
    {
        private bool eventFiringEnabledStatus;
        public EnabledItemEventsScope()
        {
            eventFiringEnabledStatus = base.EventFiringEnabled;
            base.EventFiringEnabled = true;
        }

        #region IDisposable Members
        public void Dispose()
        {
            base.EventFiringEnabled = eventFiringEnabledStatus;
        }
        #endregion
    }
}
